Skip to content

[Draft] feat: Initial codecov endpoint for fetching test results #91911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ajay-sentry
Copy link
Contributor

This PR is currently a draft.

This PR aims to create our first codecov (mocked) endpoint for test results, a "get" endpoint that calls the codecov client with different graphql queries depending on the request url.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label May 19, 2025
Copy link

codecov bot commented May 19, 2025

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
26010 2 26008 207
View the top 2 failed test(s) by shortest run time
tests.sentry.api.test_api_owners.APIOwnersTestCase::test_api_owner_owns_api
Stack Traces | 0.042s run time
#x1B[1m#x1B[.../sentry/api/test_api_owners.py#x1B[0m:22: in test_api_owner_owns_api
    assert owner.value in self.teams
#x1B[1m#x1B[31mE   AssertionError: assert 'codecov' in {'alerts-create-issues', 'alerts-notifications', 'core-product-foundations', 'crons', 'dashboards', 'data', ...}#x1B[0m
#x1B[1m#x1B[31mE    +  where 'codecov' = <ApiOwner.CODECOV: 'codecov'>.value#x1B[0m
#x1B[1m#x1B[31mE    +  and   {'alerts-create-issues', 'alerts-notifications', 'core-product-foundations', 'crons', 'dashboards', 'data', ...} = <tests.sentry.api.test_api_owners.APIOwnersTestCase testMethod=test_api_owner_owns_api>.teams#x1B[0m
tests.sentry.codecov.endpoints.test_test_results.TestResultsEndpointTest::test_get_returns_mock_response
Stack Traces | 0.366s run time
#x1B[1m#x1B[.../codecov/endpoints/test_test_results.py#x1B[0m:36: in test_get_returns_mock_response
    assert response.status_code == 200
#x1B[1m#x1B[31mE   assert 500 == 200#x1B[0m
#x1B[1m#x1B[31mE    +  where 500 = <Response status_code=500, "application/json">.status_code#x1B[0m

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

after: $after
last: $last
before: $before
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also return the after and last as part of this query right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return in the response or?

"""


class TestResultNodeSerializer(serializers.Serializer):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we adding all singular serializers the word node? You used it here to differentiate from the list, but would that lead to other singular resources having the word node too?

Copy link
Contributor

@calvin-codecov calvin-codecov May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we would for any responses that return edge nodes. We have quite a few that do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For any "list" endpoints I think the word Node makes a lot of sense since that's what the GQL response would be returning.

For single items though I don't think we'd need the word node since that wouldn't be an object returned in the GQL response, if that makes sense

variables = {
"owner": owner,
"repo": repository,
"commit": commit,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't seem to be using this variable in the query.

Also we are missing the filters, ordering and pagination vars as well right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah haha, I wasn't planning to hook everything up initially just so we could get a mock response returned to the frontend first and then work on this in tandem. But since we've merged the query convenience function now maybe I can cook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants